package com.studyyoun.android.androidcommonbaselibrary.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by androidlongs on 17/3/1.
 * 站在顶峰，看世界
 * 落在谷底，思人生
 */

public class StringUtil {
    private StringUtil () {

    }


    private static class SingleDateUtil {
        private static StringUtil sStringUtil = new StringUtil();
    }

    public static StringUtil getInstance () {
        return SingleDateUtil.sStringUtil;
    }

    /**
     * 判断邮箱是否合法
     *
     * @param email
     * @return
     */
    public static boolean isEmail (String email) {
        if (null == email || "".equals(email)) return false;
        //Pattern p = Pattern.compile("\\w+@(\\w+.)+[a-z]{2,3}"); //简单匹配
        Pattern p = Pattern.compile("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");//复杂匹配
        Matcher m = p.matcher(email);
        return m.matches();
    }


}
